package com.bw.module_merchant.activity

import android.os.Bundle
import android.view.View
import androidx.activity.viewModels
import com.blankj.utilcode.util.SPUtils




import com.bw.module_merchant.vm.EnterpriseRecordDetailViewModel
import com.example.lib_common.view.view.BaseMvvmActivity
import com.example.module_merchant.R
import com.example.module_merchant.databinding.ActivityMerchanDetailBinding


import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class MerchantDetailActivity : BaseMvvmActivity<ActivityMerchanDetailBinding>() {

    private val viewModel : EnterpriseRecordDetailViewModel by viewModels()



    override fun initViews() {


        val id = SPUtils.getInstance().getInt("merchantId")

        viewModel.getDetail(id)

        viewModel.mSuccessLiveData.observe(this){
            binding.status.text = it.data.status
            binding.applicationNumber.text = it.data.applicationNumber
            binding.enterpriseName.text = it.data.enterpriseName
            binding.applicationTime.text = it.data.processingSteps[0].stepTime
            binding.peopleName.text = it.data.contactName
            binding.applicationCount.text = "${it.data.entryPersonnel}"
            binding.applicationArea.text = "${it.data.applicationArea}m²"
            binding.merchantTime.text = it.data.entryTime

            if (it.data.processingSteps[0].id != null){

                if (it.data.processingSteps[0].business === "审核通过"){
                    binding.text2.text = "审核通过"
                }else{
                    binding.text2.text = "已驳回"
                }
                binding.lastTime.text = it.data.processingSteps[0].stepTime

            }else{
                binding.text2.visibility = View.GONE
                binding.square2.visibility = View.GONE
                binding.circle23.visibility = View.GONE
            }
        }
    }

    override fun getLayoutId(): Int = R.layout.activity_merchan_detail


    override fun getActivityState(state: Bundle) {
        TODO("Not yet implemented")
    }

    override fun saveActivityState(outState: Bundle) {
        TODO("Not yet implemented")
    }

}